/**
 * 股票搜索表单组件
 */
<template>
  <div class="stock-search-form">
    <el-form :model="form" @submit.native.prevent="handleSubmit">
      <el-form-item>
        <el-input
          v-model="form.stockCode"
          placeholder="请输入权重股"
          size="medium"
        />
      </el-form-item>

      <el-form-item>
        <el-input
          v-model="form.zzsCode"
          placeholder="请输入中证指数"
          size="medium"
        />
      </el-form-item>

      <el-form-item>
        <el-input
          v-model="form.buyDate"
          placeholder="请输入买入日期"
          size="medium"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="handleSubmit">
          搜索
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  name: 'StockSearchForm',

  props: {
    value: {
      type: Object,
      default: () => ({
        stockCode: '',
        zzsCode: '',
        buyDate: ''
      })
    }
  },

  data() {
    return {
      form: { ...this.value }
    };
  },

  watch: {
    value: {
      handler(val) {
        this.form = { ...val };
      },
      deep: true
    }
  },

  methods: {
    handleSubmit() {
      this.$emit('input', { ...this.form });
      this.$emit('search');
    }
  }
};
</script>

<style lang="scss" scoped>
.stock-search-form {
  padding: 20px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;

  .el-form-item {
    margin-bottom: 15px;

    &:last-child {
      margin-bottom: 0;
      text-align: right;
    }
  }
}
</style> 